<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" th:href="@{/css/base.css}"/>
    <link rel="stylesheet" th:href="@{/css/info-mgt.css}"/>
    <link rel="stylesheet" th:href="@{/css/WdatePicker.css}"/>
    <title>选课系统</title>
</head>

<body>
<div class="title"><h2>学生信息</h2></div>
<div class="query">
    <form method="get" action="/student/list">
        <div class="query-conditions ue-clear">
            <div class="conditions name ue-clear">
                <label>学号：</label>
                <input style="width:195px;height:25px;border:1px solid #C5D6E0" name="username" type="text">
            </div>
            <div class="conditions name ue-clear">
                <label>姓名：</label>
                <input style="width:195px;height:25px;border:1px solid #C5D6E0" name="name" type="text">
                <input style="background-color:#68B86C;color:white;border-radius:10px" type="submit" value="查询"/>
                <input style="background-color:#EFF6FA;color:black;border-radius:10px" type="reset" value="清空"/>
            </div>
        </div>
    </form>
    <form method="get" action="/student/toAddPage">
        <div class="query-btn ue-clear">
            <input style="background-color:#EFF6FA;color:black;border-radius:10px" type="submit" value="添加"/>
        </div>
    </form>
</div>
<div class="table-box">
    <table>
        <thead>
        <tr>
            <th class="name">学号</th>
            <th class="node">姓名</th>
            <th class="node">性别</th>
            <th class="node">电话</th>
            <th class="node">邮箱</th>
            <th class="node">状态</th>
            <th class="node">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="student, studentStart : ${studentList}">
            <td class="name" th:text="${student.username}"></td>
            <td class="node" th:text="${student.name}"></td>
            <td class="node" th:text="${student.sex} == 1 ? '男': '女'"></td>
            <td class="node" th:text="${student.phone}"></td>
            <td class="node" th:text="${student.email}"></td>
            <td class="node" th:text="${student.status} == 1 ? '正常': '停用'"></td>
            <td class="node">
                <a style="color:blue" th:href="${'/student/info/' + student.id}">修改</a>
                <a style="color:blue" th:onclick="del([[${student.id}]], [[${student.username}]])">删除</a>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<div class="pagination ue-clear"></div>
</body>
<script type="text/javascript" th:src="@{/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/js/common.js}"></script>
<script type="text/javascript" th:src="@{/js/WdatePicker.js}"></script>
<script type="text/javascript">
    function del(id, username) {
        if(confirm("确认删除学生：" + username + "?")){
            $.ajax({
                url: "../student/delete",
                type: "post",
                dataType: "json",
                data: {"studentId": id},
                success: function (data) {
                    alert(data.msg);
                }
            });
        }
    }
    $("tbody").find("tr:odd").css("backgroundColor", "#eff6fa");
    showRemind('input[type=text], textarea', 'placeholder');
</script>
</html>
